﻿///Author : Bui Huu Loc
///Date : 07-04-2009
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibKetoan;

namespace Ketoan
{	
	public class frmReport_kp : System.Windows.Forms.Form
	{
		#region Controls
		private int i_Iduser=0;
		private exportExcel exportExcel=new exportExcel();
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.GroupBox grpNen;
		private LibList.List listnhombc;
		private LibList.List listNguon;
		protected txtListBox.txtListBox txtTenNguonGoc;
		private txtListBox.txtListBox txtNguonGoc;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox txttenhoatdong;
		private System.Windows.Forms.TextBox txthoatdong;
		private LibList.List listchuong;
		private System.Windows.Forms.TextBox txttenchuong;
		private System.Windows.Forms.TextBox txtchuong;
		private System.Windows.Forms.TextBox txtnhombc;
		private System.Windows.Forms.TextBox txttennhombc;
		private System.Windows.Forms.Label lblnhombc;
		private System.Windows.Forms.Label lblChuong;
		private System.Windows.Forms.Label lblHoatDong;
		private LibList.List listLoaikhoan;
		private LibList.List listhoatdong;
		private System.Windows.Forms.GroupBox grbThang;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.NumericUpDown numNam;
		private System.Windows.Forms.Label lblDenthang;
		private System.Windows.Forms.Label lblNam;
		private txtListBox.txtListBox txtTenloaikhoan;
		private txtListBox.txtListBox txtLoaikhoan;
		private System.Windows.Forms.Label lblLoaikhoan;
		private System.Windows.Forms.ComboBox cboChonQuy;
		private System.Windows.Forms.NumericUpDown numQuy;
		private System.Windows.Forms.Panel pnlButton;
		private System.Windows.Forms.Button butExcel;
		private System.Windows.Forms.Button butKetthuc;
		private System.Windows.Forms.Button butIn;
		private System.Windows.Forms.Button butXem;
		private System.Windows.Forms.CheckBox chkCheck;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		#endregion

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmReport_kp));
			this.panel1 = new System.Windows.Forms.Panel();
			this.pnlButton = new System.Windows.Forms.Panel();
			this.butExcel = new System.Windows.Forms.Button();
			this.butKetthuc = new System.Windows.Forms.Button();
			this.butIn = new System.Windows.Forms.Button();
			this.butXem = new System.Windows.Forms.Button();
			this.grpNen = new System.Windows.Forms.GroupBox();
			this.chkCheck = new System.Windows.Forms.CheckBox();
			this.listnhombc = new LibList.List();
			this.listNguon = new LibList.List();
			this.txtTenNguonGoc = new txtListBox.txtListBox();
			this.txtNguonGoc = new txtListBox.txtListBox();
			this.label4 = new System.Windows.Forms.Label();
			this.txttenhoatdong = new System.Windows.Forms.TextBox();
			this.txthoatdong = new System.Windows.Forms.TextBox();
			this.listchuong = new LibList.List();
			this.txttenchuong = new System.Windows.Forms.TextBox();
			this.txtchuong = new System.Windows.Forms.TextBox();
			this.txtnhombc = new System.Windows.Forms.TextBox();
			this.txttennhombc = new System.Windows.Forms.TextBox();
			this.txtTenloaikhoan = new txtListBox.txtListBox();
			this.txtLoaikhoan = new txtListBox.txtListBox();
			this.lblnhombc = new System.Windows.Forms.Label();
			this.lblChuong = new System.Windows.Forms.Label();
			this.lblHoatDong = new System.Windows.Forms.Label();
			this.lblLoaikhoan = new System.Windows.Forms.Label();
			this.listLoaikhoan = new LibList.List();
			this.listhoatdong = new LibList.List();
			this.grbThang = new System.Windows.Forms.GroupBox();
			this.cboChonQuy = new System.Windows.Forms.ComboBox();
			this.label1 = new System.Windows.Forms.Label();
			this.numQuy = new System.Windows.Forms.NumericUpDown();
			this.numNam = new System.Windows.Forms.NumericUpDown();
			this.lblDenthang = new System.Windows.Forms.Label();
			this.lblNam = new System.Windows.Forms.Label();
			this.panel1.SuspendLayout();
			this.pnlButton.SuspendLayout();
			this.grpNen.SuspendLayout();
			this.grbThang.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.numQuy)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.numNam)).BeginInit();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.pnlButton,
																				 this.grpNen,
																				 this.grbThang});
			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel1.DockPadding.All = 5;
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(482, 264);
			this.panel1.TabIndex = 1;
			// 
			// pnlButton
			// 
			this.pnlButton.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.butExcel,
																					this.butKetthuc,
																					this.butIn,
																					this.butXem});
			this.pnlButton.Dock = System.Windows.Forms.DockStyle.Fill;
			this.pnlButton.Location = new System.Drawing.Point(5, 216);
			this.pnlButton.Name = "pnlButton";
			this.pnlButton.Size = new System.Drawing.Size(472, 43);
			this.pnlButton.TabIndex = 179;
			// 
			// butExcel
			// 
			this.butExcel.BackColor = System.Drawing.SystemColors.Control;
			this.butExcel.ForeColor = System.Drawing.SystemColors.WindowText;
			this.butExcel.Image = ((System.Drawing.Bitmap)(resources.GetObject("butExcel.Image")));
			this.butExcel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butExcel.Location = new System.Drawing.Point(164, 8);
			this.butExcel.Name = "butExcel";
			this.butExcel.Size = new System.Drawing.Size(68, 25);
			this.butExcel.TabIndex = 187;
			this.butExcel.Text = "     &Excel";
			this.butExcel.Click += new System.EventHandler(this.butExcel_Click);
			// 
			// butKetthuc
			// 
			this.butKetthuc.BackColor = System.Drawing.SystemColors.Control;
			this.butKetthuc.ForeColor = System.Drawing.SystemColors.WindowText;
			this.butKetthuc.Image = ((System.Drawing.Bitmap)(resources.GetObject("butKetthuc.Image")));
			this.butKetthuc.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butKetthuc.Location = new System.Drawing.Point(316, 8);
			this.butKetthuc.Name = "butKetthuc";
			this.butKetthuc.Size = new System.Drawing.Size(68, 25);
			this.butKetthuc.TabIndex = 189;
			this.butKetthuc.Text = "&Kết thúc";
			this.butKetthuc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			this.butKetthuc.Click += new System.EventHandler(this.butKetthuc_Click);
			// 
			// butIn
			// 
			this.butIn.BackColor = System.Drawing.SystemColors.Control;
			this.butIn.ForeColor = System.Drawing.SystemColors.WindowText;
			this.butIn.Image = ((System.Drawing.Bitmap)(resources.GetObject("butIn.Image")));
			this.butIn.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butIn.Location = new System.Drawing.Point(236, 8);
			this.butIn.Name = "butIn";
			this.butIn.Size = new System.Drawing.Size(68, 25);
			this.butIn.TabIndex = 188;
			this.butIn.Text = "     &In";
			this.butIn.Click += new System.EventHandler(this.butIn_Click);
			// 
			// butXem
			// 
			this.butXem.BackColor = System.Drawing.SystemColors.Control;
			this.butXem.ForeColor = System.Drawing.SystemColors.WindowText;
			this.butXem.Image = ((System.Drawing.Bitmap)(resources.GetObject("butXem.Image")));
			this.butXem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.butXem.Location = new System.Drawing.Point(92, 8);
			this.butXem.Name = "butXem";
			this.butXem.Size = new System.Drawing.Size(68, 25);
			this.butXem.TabIndex = 186;
			this.butXem.Text = "     &Xem";
			this.butXem.Click += new System.EventHandler(this.butXem_Click);
			// 
			// grpNen
			// 
			this.grpNen.BackColor = System.Drawing.SystemColors.Control;
			this.grpNen.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.chkCheck,
																				 this.listnhombc,
																				 this.listNguon,
																				 this.txtTenNguonGoc,
																				 this.txtNguonGoc,
																				 this.label4,
																				 this.txttenhoatdong,
																				 this.txthoatdong,
																				 this.listchuong,
																				 this.txttenchuong,
																				 this.txtchuong,
																				 this.txtnhombc,
																				 this.txttennhombc,
																				 this.txtTenloaikhoan,
																				 this.txtLoaikhoan,
																				 this.lblnhombc,
																				 this.lblChuong,
																				 this.lblHoatDong,
																				 this.lblLoaikhoan,
																				 this.listLoaikhoan,
																				 this.listhoatdong});
			this.grpNen.Dock = System.Windows.Forms.DockStyle.Top;
			this.grpNen.Location = new System.Drawing.Point(5, 48);
			this.grpNen.Name = "grpNen";
			this.grpNen.Size = new System.Drawing.Size(472, 168);
			this.grpNen.TabIndex = 174;
			this.grpNen.TabStop = false;
			// 
			// chkCheck
			// 
			this.chkCheck.ForeColor = System.Drawing.Color.DarkBlue;
			this.chkCheck.Location = new System.Drawing.Point(400, 144);
			this.chkCheck.Name = "chkCheck";
			this.chkCheck.Size = new System.Drawing.Size(64, 16);
			this.chkCheck.TabIndex = 187;
			this.chkCheck.Text = "Lũy Kế";
			this.chkCheck.CheckedChanged += new System.EventHandler(this.chkCheck_CheckedChanged);
			// 
			// listnhombc
			// 
			this.listnhombc.BackColor = System.Drawing.SystemColors.Info;
			this.listnhombc.ColumnCount = 0;
			this.listnhombc.Location = new System.Drawing.Point(160, 16);
			this.listnhombc.MatchBufferTimeOut = 1000;
			this.listnhombc.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listnhombc.Name = "listnhombc";
			this.listnhombc.Size = new System.Drawing.Size(80, 17);
			this.listnhombc.TabIndex = 186;
			this.listnhombc.TextIndex = -1;
			this.listnhombc.TextMember = null;
			this.listnhombc.ValueIndex = -1;
			this.listnhombc.Visible = false;
			// 
			// listNguon
			// 
			this.listNguon.BackColor = System.Drawing.SystemColors.Info;
			this.listNguon.ColumnCount = 0;
			this.listNguon.Location = new System.Drawing.Point(160, 88);
			this.listNguon.MatchBufferTimeOut = 1000;
			this.listNguon.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listNguon.Name = "listNguon";
			this.listNguon.Size = new System.Drawing.Size(75, 17);
			this.listNguon.TabIndex = 165;
			this.listNguon.TextIndex = -1;
			this.listNguon.TextMember = null;
			this.listNguon.ValueIndex = -1;
			this.listNguon.Visible = false;
			// 
			// txtTenNguonGoc
			// 
			this.txtTenNguonGoc.BackColor = System.Drawing.SystemColors.Window;
			this.txtTenNguonGoc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTenNguonGoc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTenNguonGoc.Location = new System.Drawing.Point(160, 88);
			this.txtTenNguonGoc.Name = "txtTenNguonGoc";
			this.txtTenNguonGoc.ReadOnly = true;
			this.txtTenNguonGoc.Size = new System.Drawing.Size(304, 21);
			this.txtTenNguonGoc.TabIndex = 163;
			this.txtTenNguonGoc.TabStop = false;
			this.txtTenNguonGoc.Text = "";
			this.txtTenNguonGoc.Leave += new System.EventHandler(this.txtTenNguonGoc_Leave);
			this.txtTenNguonGoc.Enter += new System.EventHandler(this.txtTenNguonGoc_Enter);
			// 
			// txtNguonGoc
			// 
			this.txtNguonGoc.BackColor = System.Drawing.SystemColors.Window;
			this.txtNguonGoc.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtNguonGoc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtNguonGoc.Location = new System.Drawing.Point(96, 88);
			this.txtNguonGoc.Name = "txtNguonGoc";
			this.txtNguonGoc.Size = new System.Drawing.Size(63, 21);
			this.txtNguonGoc.TabIndex = 162;
			this.txtNguonGoc.Text = "";
			this.txtNguonGoc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtNguonGoc_KeyDown);
			this.txtNguonGoc.Leave += new System.EventHandler(this.txtNguonGoc_Leave);
			this.txtNguonGoc.DoubleClick += new System.EventHandler(this.txtNguonGoc_DoubleClick);
			this.txtNguonGoc.Validated += new System.EventHandler(this.txtNguonGoc_Validated);
			this.txtNguonGoc.TextChanged += new System.EventHandler(this.txtNguonGoc_TextChanged);
			this.txtNguonGoc.Enter += new System.EventHandler(this.txtNguonGoc_Enter);
			// 
			// label4
			// 
			this.label4.BackColor = System.Drawing.SystemColors.Control;
			this.label4.ForeColor = System.Drawing.Color.DarkBlue;
			this.label4.Location = new System.Drawing.Point(24, 88);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 23);
			this.label4.TabIndex = 164;
			this.label4.Text = "Nguồn :";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// txttenhoatdong
			// 
			this.txttenhoatdong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txttenhoatdong.Location = new System.Drawing.Point(160, 64);
			this.txttenhoatdong.Name = "txttenhoatdong";
			this.txttenhoatdong.Size = new System.Drawing.Size(304, 20);
			this.txttenhoatdong.TabIndex = 38;
			this.txttenhoatdong.Text = "";
			this.txttenhoatdong.Leave += new System.EventHandler(this.txttenhoatdong_Leave);
			this.txttenhoatdong.Enter += new System.EventHandler(this.txttenhoatdong_Enter);
			// 
			// txthoatdong
			// 
			this.txthoatdong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txthoatdong.Location = new System.Drawing.Point(96, 64);
			this.txthoatdong.Name = "txthoatdong";
			this.txthoatdong.Size = new System.Drawing.Size(63, 20);
			this.txthoatdong.TabIndex = 37;
			this.txthoatdong.Text = "";
			this.txthoatdong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txthoatdong_KeyDown);
			this.txthoatdong.Validated += new System.EventHandler(this.txthoatdong_Validated);
			this.txthoatdong.TextChanged += new System.EventHandler(this.txthoatdong_TextChanged);
			this.txthoatdong.DoubleClick += new System.EventHandler(this.txthoatdong_DoubleClick);
			this.txthoatdong.Leave += new System.EventHandler(this.txthoatdong_Leave);
			this.txthoatdong.Enter += new System.EventHandler(this.txthoatdong_Enter);
			// 
			// listchuong
			// 
			this.listchuong.BackColor = System.Drawing.SystemColors.Info;
			this.listchuong.ColumnCount = 0;
			this.listchuong.Location = new System.Drawing.Point(160, 40);
			this.listchuong.MatchBufferTimeOut = 1000;
			this.listchuong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listchuong.Name = "listchuong";
			this.listchuong.Size = new System.Drawing.Size(75, 17);
			this.listchuong.TabIndex = 153;
			this.listchuong.TextIndex = -1;
			this.listchuong.TextMember = null;
			this.listchuong.ValueIndex = -1;
			this.listchuong.Visible = false;
			// 
			// txttenchuong
			// 
			this.txttenchuong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txttenchuong.Location = new System.Drawing.Point(160, 40);
			this.txttenchuong.Name = "txttenchuong";
			this.txttenchuong.Size = new System.Drawing.Size(304, 20);
			this.txttenchuong.TabIndex = 36;
			this.txttenchuong.Text = "";
			this.txttenchuong.Leave += new System.EventHandler(this.txttenchuong_Leave);
			this.txttenchuong.Enter += new System.EventHandler(this.txttenchuong_Enter);
			// 
			// txtchuong
			// 
			this.txtchuong.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtchuong.Location = new System.Drawing.Point(96, 40);
			this.txtchuong.Name = "txtchuong";
			this.txtchuong.Size = new System.Drawing.Size(63, 20);
			this.txtchuong.TabIndex = 35;
			this.txtchuong.Text = "";
			this.txtchuong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtchuong_KeyDown);
			this.txtchuong.Validated += new System.EventHandler(this.txtchuong_Validated);
			this.txtchuong.TextChanged += new System.EventHandler(this.txtchuong_TextChanged);
			this.txtchuong.DoubleClick += new System.EventHandler(this.txtchuong_DoubleClick);
			this.txtchuong.Leave += new System.EventHandler(this.txtchuong_Leave);
			this.txtchuong.Enter += new System.EventHandler(this.txtchuong_Enter);
			// 
			// txtnhombc
			// 
			this.txtnhombc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtnhombc.Location = new System.Drawing.Point(96, 16);
			this.txtnhombc.Name = "txtnhombc";
			this.txtnhombc.Size = new System.Drawing.Size(63, 20);
			this.txtnhombc.TabIndex = 33;
			this.txtnhombc.Text = "";
			this.txtnhombc.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtnhombc_KeyDown);
			this.txtnhombc.Validated += new System.EventHandler(this.txtnhombc_Validated);
			this.txtnhombc.TextChanged += new System.EventHandler(this.txtnhombc_TextChanged);
			this.txtnhombc.DoubleClick += new System.EventHandler(this.txtnhombc_DoubleClick);
			this.txtnhombc.Leave += new System.EventHandler(this.txtnhombc_Leave);
			this.txtnhombc.Enter += new System.EventHandler(this.txtnhombc_Enter);
			// 
			// txttennhombc
			// 
			this.txttennhombc.ForeColor = System.Drawing.Color.DarkBlue;
			this.txttennhombc.Location = new System.Drawing.Point(160, 16);
			this.txttennhombc.Name = "txttennhombc";
			this.txttennhombc.Size = new System.Drawing.Size(304, 20);
			this.txttennhombc.TabIndex = 34;
			this.txttennhombc.Text = "";
			this.txttennhombc.Leave += new System.EventHandler(this.txttennhombc_Leave);
			this.txttennhombc.Enter += new System.EventHandler(this.txttennhombc_Enter);
			// 
			// txtTenloaikhoan
			// 
			this.txtTenloaikhoan.BackColor = System.Drawing.SystemColors.Window;
			this.txtTenloaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtTenloaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtTenloaikhoan.Location = new System.Drawing.Point(160, 112);
			this.txtTenloaikhoan.Name = "txtTenloaikhoan";
			this.txtTenloaikhoan.ReadOnly = true;
			this.txtTenloaikhoan.Size = new System.Drawing.Size(304, 21);
			this.txtTenloaikhoan.TabIndex = 40;
			this.txtTenloaikhoan.TabStop = false;
			this.txtTenloaikhoan.Text = "";
			this.txtTenloaikhoan.Leave += new System.EventHandler(this.txtTenloaikhoan_Leave);
			this.txtTenloaikhoan.Enter += new System.EventHandler(this.txtTenloaikhoan_Enter);
			// 
			// txtLoaikhoan
			// 
			this.txtLoaikhoan.BackColor = System.Drawing.SystemColors.Window;
			this.txtLoaikhoan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.txtLoaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
			this.txtLoaikhoan.Location = new System.Drawing.Point(96, 112);
			this.txtLoaikhoan.Name = "txtLoaikhoan";
			this.txtLoaikhoan.Size = new System.Drawing.Size(63, 21);
			this.txtLoaikhoan.TabIndex = 39;
			this.txtLoaikhoan.Text = "";
			this.txtLoaikhoan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtLoaikhoan_KeyDown);
			this.txtLoaikhoan.Leave += new System.EventHandler(this.txtLoaikhoan_Leave);
			this.txtLoaikhoan.DoubleClick += new System.EventHandler(this.txtLoaikhoan_DoubleClick);
			this.txtLoaikhoan.Validated += new System.EventHandler(this.txtLoaikhoan_Validated);
			this.txtLoaikhoan.TextChanged += new System.EventHandler(this.txtLoaikhoan_TextChanged);
			this.txtLoaikhoan.Enter += new System.EventHandler(this.txtLoaikhoan_Enter);
			// 
			// lblnhombc
			// 
			this.lblnhombc.BackColor = System.Drawing.SystemColors.Control;
			this.lblnhombc.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblnhombc.Location = new System.Drawing.Point(8, 15);
			this.lblnhombc.Name = "lblnhombc";
			this.lblnhombc.Size = new System.Drawing.Size(88, 23);
			this.lblnhombc.TabIndex = 126;
			this.lblnhombc.Text = "Nhóm báo cáo:";
			this.lblnhombc.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lblChuong
			// 
			this.lblChuong.BackColor = System.Drawing.SystemColors.Control;
			this.lblChuong.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblChuong.Location = new System.Drawing.Point(16, 39);
			this.lblChuong.Name = "lblChuong";
			this.lblChuong.Size = new System.Drawing.Size(80, 23);
			this.lblChuong.TabIndex = 137;
			this.lblChuong.Text = "Chương:";
			this.lblChuong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lblHoatDong
			// 
			this.lblHoatDong.BackColor = System.Drawing.SystemColors.Control;
			this.lblHoatDong.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblHoatDong.Location = new System.Drawing.Point(16, 63);
			this.lblHoatDong.Name = "lblHoatDong";
			this.lblHoatDong.Size = new System.Drawing.Size(80, 23);
			this.lblHoatDong.TabIndex = 138;
			this.lblHoatDong.Text = "Hoạt động:";
			this.lblHoatDong.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lblLoaikhoan
			// 
			this.lblLoaikhoan.BackColor = System.Drawing.SystemColors.Control;
			this.lblLoaikhoan.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblLoaikhoan.Location = new System.Drawing.Point(24, 112);
			this.lblLoaikhoan.Name = "lblLoaikhoan";
			this.lblLoaikhoan.Size = new System.Drawing.Size(72, 23);
			this.lblLoaikhoan.TabIndex = 33;
			this.lblLoaikhoan.Text = "Loại khoản :";
			this.lblLoaikhoan.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// listLoaikhoan
			// 
			this.listLoaikhoan.BackColor = System.Drawing.SystemColors.Info;
			this.listLoaikhoan.ColumnCount = 0;
			this.listLoaikhoan.Location = new System.Drawing.Point(160, 112);
			this.listLoaikhoan.MatchBufferTimeOut = 1000;
			this.listLoaikhoan.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listLoaikhoan.Name = "listLoaikhoan";
			this.listLoaikhoan.Size = new System.Drawing.Size(72, 17);
			this.listLoaikhoan.TabIndex = 184;
			this.listLoaikhoan.TextIndex = -1;
			this.listLoaikhoan.TextMember = null;
			this.listLoaikhoan.ValueIndex = -1;
			this.listLoaikhoan.Visible = false;
			// 
			// listhoatdong
			// 
			this.listhoatdong.BackColor = System.Drawing.SystemColors.Info;
			this.listhoatdong.ColumnCount = 0;
			this.listhoatdong.Location = new System.Drawing.Point(168, 64);
			this.listhoatdong.MatchBufferTimeOut = 1000;
			this.listhoatdong.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
			this.listhoatdong.Name = "listhoatdong";
			this.listhoatdong.Size = new System.Drawing.Size(56, 17);
			this.listhoatdong.TabIndex = 185;
			this.listhoatdong.TextIndex = -1;
			this.listhoatdong.TextMember = null;
			this.listhoatdong.ValueIndex = -1;
			this.listhoatdong.Visible = false;
			// 
			// grbThang
			// 
			this.grbThang.Controls.AddRange(new System.Windows.Forms.Control[] {
																				   this.cboChonQuy,
																				   this.label1,
																				   this.numQuy,
																				   this.numNam,
																				   this.lblDenthang,
																				   this.lblNam});
			this.grbThang.Dock = System.Windows.Forms.DockStyle.Top;
			this.grbThang.Location = new System.Drawing.Point(5, 5);
			this.grbThang.Name = "grbThang";
			this.grbThang.Size = new System.Drawing.Size(472, 43);
			this.grbThang.TabIndex = 178;
			this.grbThang.TabStop = false;
			// 
			// cboChonQuy
			// 
			this.cboChonQuy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboChonQuy.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cboChonQuy.ForeColor = System.Drawing.Color.DarkBlue;
			this.cboChonQuy.ImeMode = System.Windows.Forms.ImeMode.NoControl;
			this.cboChonQuy.Items.AddRange(new object[] {
															"Quý",
															"Năm"});
			this.cboChonQuy.Location = new System.Drawing.Point(96, 16);
			this.cboChonQuy.Name = "cboChonQuy";
			this.cboChonQuy.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.cboChonQuy.Size = new System.Drawing.Size(107, 21);
			this.cboChonQuy.TabIndex = 19;
			this.cboChonQuy.SelectedValueChanged += new System.EventHandler(this.cboChonQuy_SelectedValueChanged);
			this.cboChonQuy.Leave += new System.EventHandler(this.cboChonQuy_Leave);
			this.cboChonQuy.Enter += new System.EventHandler(this.cboChonQuy_Enter);
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.SystemColors.Control;
			this.label1.ForeColor = System.Drawing.Color.DarkBlue;
			this.label1.Location = new System.Drawing.Point(8, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(80, 23);
			this.label1.TabIndex = 18;
			this.label1.Text = "Báo cáo theo :";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// numQuy
			// 
			this.numQuy.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.numQuy.ForeColor = System.Drawing.Color.DarkBlue;
			this.numQuy.Location = new System.Drawing.Point(336, 16);
			this.numQuy.Maximum = new System.Decimal(new int[] {
																   4,
																   0,
																   0,
																   0});
			this.numQuy.Minimum = new System.Decimal(new int[] {
																   1,
																   0,
																   0,
																   0});
			this.numQuy.Name = "numQuy";
			this.numQuy.Size = new System.Drawing.Size(38, 21);
			this.numQuy.TabIndex = 24;
			this.numQuy.Value = new System.Decimal(new int[] {
																 1,
																 0,
																 0,
																 0});
			this.numQuy.Enter += new System.EventHandler(this.numQuy_Enter);
			this.numQuy.Leave += new System.EventHandler(this.numQuy_Leave);
			// 
			// numNam
			// 
			this.numNam.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.numNam.ForeColor = System.Drawing.Color.DarkBlue;
			this.numNam.Location = new System.Drawing.Point(416, 16);
			this.numNam.Maximum = new System.Decimal(new int[] {
																   3004,
																   0,
																   0,
																   0});
			this.numNam.Minimum = new System.Decimal(new int[] {
																   2004,
																   0,
																   0,
																   0});
			this.numNam.Name = "numNam";
			this.numNam.Size = new System.Drawing.Size(48, 21);
			this.numNam.TabIndex = 25;
			this.numNam.Value = new System.Decimal(new int[] {
																 2004,
																 0,
																 0,
																 0});
			this.numNam.Enter += new System.EventHandler(this.numNam_Enter);
			this.numNam.Leave += new System.EventHandler(this.numNam_Leave);
			// 
			// lblDenthang
			// 
			this.lblDenthang.BackColor = System.Drawing.SystemColors.Control;
			this.lblDenthang.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblDenthang.Location = new System.Drawing.Point(296, 16);
			this.lblDenthang.Name = "lblDenthang";
			this.lblDenthang.Size = new System.Drawing.Size(32, 23);
			this.lblDenthang.TabIndex = 22;
			this.lblDenthang.Text = "Quý";
			this.lblDenthang.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// lblNam
			// 
			this.lblNam.BackColor = System.Drawing.SystemColors.Control;
			this.lblNam.ForeColor = System.Drawing.Color.DarkBlue;
			this.lblNam.Location = new System.Drawing.Point(376, 16);
			this.lblNam.Name = "lblNam";
			this.lblNam.Size = new System.Drawing.Size(34, 23);
			this.lblNam.TabIndex = 23;
			this.lblNam.Text = "Năm";
			this.lblNam.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// frmReport_kp
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(482, 264);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.panel1});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
			this.Name = "frmReport_kp";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Load += new System.EventHandler(this.frmReport_kp_Load);
			this.panel1.ResumeLayout(false);
			this.pnlButton.ResumeLayout(false);
			this.grpNen.ResumeLayout(false);
			this.grbThang.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.numQuy)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numNam)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		#region Variable
		//Khai bao gia tri mau cho form
		private int i_Red=255,i_Green=255,i_Blue=195;
		//private bool kt_chon_da=false;
		//private bool kt_chon_kp=false;
		private AccessData a;
		//Khai bao bien su dung trong form.
		private string s_Tenform="";
		private int i_HTaikhoan=0,i_HLoaikhoan=0;	
		private Print Print=new Print();
		private DataRow r;
		private System.Data.DataTable dtDmtk,dtDmlk, dtDmnhombc,dtDmChuong,dtDmHoatdong,dtDmNhomMuc,dtDmNguon;
		private DataSet ds_Data;
		bool check=false;
		//		private DataSet ds=new DataSet();
		string Madvqhns="",text="",ngaythangnam="";
		private string s_Report="",s_loaidutoan="",s_loai="",s_khoan="",s_nhommuc="",ngayin="";		
		private bool b_Nguon = true;
		#endregion

		#region Constructor
		public frmReport_kp(string s_Form,AccessData acc,int i_iduser)
		{		
			InitializeComponent();
			a=acc;
			s_Tenform=s_Form;
			i_Iduser=i_iduser;
		}
		#endregion

		#region Destructor
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#endregion

		#region Load Form
		private void frmReport_kp_Load(object sender, System.EventArgs e)
		{		
			cboChonQuy.SelectedIndex=1;
			numQuy.Value=1;
			numNam.Value=DateTime.Now.Year;
			ngayin = "Ngày " + DateTime.Now.Day.ToString() + " tháng ";
			ngayin += DateTime.Now.Month + " năm " + DateTime.Now.Year.ToString();
			f_Loadform();
			f_Loaddm();		
		}
		#endregion

		#region Control Events
		#region Button Events
		private void butXem_Click(object sender, System.EventArgs e)
		{
			
			if (s_Tenform=="TongHopKP")
			{
				Display_(1);	
			}
			else
			{
				Display(1);	
			}
			
		}

		private void butExcel_Click(object sender, System.EventArgs e)
		{
			Display(2);
		}

		private void butIn_Click(object sender, System.EventArgs e)
		{
		
		}

		private void butKetthuc_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
		#endregion

		#region Textbox Events
		//NHOM BAO CAO
		private void txtnhombc_DoubleClick(object sender, System.EventArgs e)
		{
			listnhombc.Focus();
			Filter_List(txtnhombc.Text,2);
			listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtchuong.Location.X,txtnhombc.Location.Y+15,txtnhombc.Width+0+txttennhombc.Width,txtnhombc.Height+i_HTaikhoan,100);
		}

		private void txtnhombc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listnhombc.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listnhombc.Visible) listnhombc.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtnhombc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtnhombc)
			{
				Filter_List(txtnhombc.Text,2);
				listnhombc.BrowseToDmtk(txtnhombc,txttennhombc,txtchuong,txtchuong.Location.X,txtnhombc.Location.Y+15,txtnhombc.Width+0+txttennhombc.Width,txtnhombc.Height+i_HTaikhoan,100);
			}
		}

		private void txtnhombc_Validated(object sender, System.EventArgs e)
		{
			txttennhombc.Text="";
			if (txtnhombc.Text!="")
			{
				r=a.getrowbyid(dtDmnhombc,"ma='"+txtnhombc.Text.Trim()+"'");
				if (r!=null) 
				{
					txttennhombc.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}


		//CHUONG
		private void txtchuong_DoubleClick(object sender, System.EventArgs e)
		{
			listchuong.Focus();
			Filter_List(txtchuong.Text,3);			
			listchuong.BrowseToDmtk(txtchuong,txttenchuong,txthoatdong,txtchuong.Location.X,txtchuong.Location.Y+15,txtchuong.Width+0+txttenchuong.Width,txtchuong.Height+i_HLoaikhoan,100);								
		}

		private void txtchuong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listchuong.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listchuong.Visible) listchuong.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtchuong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtchuong)
			{
				Filter_List(txtchuong.Text,3);			
				listchuong.BrowseToDmtk(txtchuong,txttenchuong,txthoatdong,txtchuong.Location.X,txtchuong.Location.Y+15,txtchuong.Width+0+txttenchuong.Width,txtchuong.Height+i_HLoaikhoan,100);								
			}
		}

		private void txtchuong_Validated(object sender, System.EventArgs e)
		{
			txttenchuong.Text="";
			if (txtchuong.Text!="")
			{
				r=a.getrowbyid(dtDmChuong,"ma='"+txtchuong.Text.Trim()+"'");
				if (r!=null) 
				{
					txttenchuong.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}


		//HOAT DONG
		private void txthoatdong_DoubleClick(object sender, System.EventArgs e)
		{
			listhoatdong.Focus();
			Filter_List(txthoatdong.Text,4);
			listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtNguonGoc,txthoatdong.Location.X,txthoatdong.Location.Y +15,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height+i_HLoaikhoan,100);							
		}

		private void txthoatdong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listhoatdong.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listhoatdong.Visible) listhoatdong.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txthoatdong_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txthoatdong)
			{
				Filter_List(txthoatdong.Text,4);
				listhoatdong.BrowseToDmtk(txthoatdong,txttenhoatdong,txtNguonGoc,txthoatdong.Location.X,txthoatdong.Location.Y +15,txthoatdong.Width+0+txttenhoatdong.Width,txthoatdong.Height+i_HLoaikhoan,100);							
			}
		}

		private void txthoatdong_Validated(object sender, System.EventArgs e)
		{
			txttenhoatdong.Text="";
			if (txthoatdong.Text!="")
			{
				r=a.getrowbyid(dtDmHoatdong,"ma='"+txthoatdong.Text.Trim()+"'");
				if (r!=null) 
				{
					txttenhoatdong.Text=r["ten"].ToString();					
				}
			}
			hide_List();
		}


		//NGUON GOC
		private void txtNguonGoc_DoubleClick(object sender, System.EventArgs e)
		{
			listNguon.Focus();
			Filter_List(txtNguonGoc.Text,6);
			listNguon.BrowseToDmtk(txtNguonGoc,txtTenNguonGoc,txtLoaikhoan,txtLoaikhoan.Location.X,txtnhombc.Location.Y-23,txtNguonGoc.Width+0+txtTenNguonGoc.Width,txtNguonGoc.Height,100);				
		}

		private void txtNguonGoc_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listNguon.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listNguon.Visible) 
				{
					listNguon.Focus();
					SendKeys.Send("{Down}");
				}
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtNguonGoc_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtNguonGoc)
			{
				Filter_List(txtNguonGoc.Text,6);
				listNguon.BrowseToDmtk(txtNguonGoc,txtTenNguonGoc,txtLoaikhoan,txtLoaikhoan.Location.X,txtnhombc.Location.Y-23,txtNguonGoc.Width+0+txtTenNguonGoc.Width,txtNguonGoc.Height,100);				
			}
		}

		private void txtNguonGoc_Validated(object sender, System.EventArgs e)
		{
			txtTenNguonGoc.Text="";
			if (txtNguonGoc.Text!="")
			{
				r=a.getrowbyid(dtDmNguon,"mang='"+txtNguonGoc.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenNguonGoc.Text=r["ten"].ToString();
				}
			}
			hide_List();
		}


		//LOAI KHOAN
		private void txtLoaikhoan_DoubleClick(object sender, System.EventArgs e)
		{
			listLoaikhoan.Focus();
			Filter_List(txtLoaikhoan.Text,5);			
			listLoaikhoan.BrowseToDmtk(txtLoaikhoan,txtTenloaikhoan,butXem,txtLoaikhoan.Location.X,txtLoaikhoan.Location.Y-90,txtLoaikhoan.Width+0+txtTenloaikhoan.Width,txtLoaikhoan.Height+i_HLoaikhoan,100);
		}

		private void txtLoaikhoan_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyCode==Keys.Down || e.KeyCode==Keys.Up) listLoaikhoan.Focus();
			else if (e.KeyCode==Keys.Enter || e.KeyCode==Keys.Tab)
			{
				if (listLoaikhoan.Visible) listLoaikhoan.Focus();
				else SendKeys.Send("{Tab}");
			}
		}

		private void txtLoaikhoan_TextChanged(object sender, System.EventArgs e)
		{
			if (this.ActiveControl==txtLoaikhoan)
			{
				Filter_List(txtLoaikhoan.Text,5);			
				listLoaikhoan.BrowseToDmtk(txtLoaikhoan,txtTenloaikhoan,butXem,txtLoaikhoan.Location.X,txtLoaikhoan.Location.Y-90,txtLoaikhoan.Width+0+txtTenloaikhoan.Width,txtLoaikhoan.Height+i_HLoaikhoan,100);
			}
		}

		private void txtLoaikhoan_Validated(object sender, System.EventArgs e)
		{
			txtTenloaikhoan.Text="";
			if (txtLoaikhoan.Text!="")
			{
				r=a.getrowbyid(dtDmlk,"lk='"+txtLoaikhoan.Text.Trim()+"'");
				if (r!=null) 
				{
					txtTenloaikhoan.Text=r["tlk"].ToString();
				}
			}
			hide_List();
		}
		#endregion

		#region Enter - Leave
		private void cboChonQuy_Enter(object sender, System.EventArgs e)
		{
			this.cboChonQuy.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void numNam_Enter(object sender, System.EventArgs e)
		{
			this.numNam.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		
		}

		private void numQuy_Enter(object sender, System.EventArgs e)
		{
			this.numQuy.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		
		}
		private void cboChonQuy_Leave(object sender, System.EventArgs e)
		{
			this.cboChonQuy.BackColor =Color.White;
		}

		private void numQuy_Leave(object sender, System.EventArgs e)
		{
			this.numQuy.BackColor =Color.White;
		}

		private void numNam_Leave(object sender, System.EventArgs e)
		{
			this.numNam.BackColor =Color.White;
		}

		private void txtnhombc_Enter(object sender, System.EventArgs e)
		{
			this.txtnhombc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtnhombc_Leave(object sender, System.EventArgs e)
		{
			this.txtnhombc.BackColor =Color.White;
		}

		private void txttennhombc_Enter(object sender, System.EventArgs e)
		{
			this.txttennhombc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txttennhombc_Leave(object sender, System.EventArgs e)
		{
			this.txttennhombc.BackColor =Color.White;
		}

		private void txtchuong_Enter(object sender, System.EventArgs e)
		{
			this.txtchuong.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtchuong_Leave(object sender, System.EventArgs e)
		{
			this.txtchuong.BackColor =Color.White;
		}

		private void txttenchuong_Enter(object sender, System.EventArgs e)
		{
			this.txttenchuong.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txttenchuong_Leave(object sender, System.EventArgs e)
		{
			this.txttenchuong.BackColor =Color.White;
		}

		private void txthoatdong_Enter(object sender, System.EventArgs e)
		{
			this.txthoatdong.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txthoatdong_Leave(object sender, System.EventArgs e)
		{
			this.txthoatdong.BackColor =Color.White;
		}

		private void txttenhoatdong_Enter(object sender, System.EventArgs e)
		{
			this.txttenhoatdong.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txttenhoatdong_Leave(object sender, System.EventArgs e)
		{
			this.txttenhoatdong.BackColor =Color.White;
		}

		private void txtNguonGoc_Enter(object sender, System.EventArgs e)
		{
			this.txtNguonGoc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtNguonGoc_Leave(object sender, System.EventArgs e)
		{
			this.txtNguonGoc.BackColor =Color.White;
		}

		private void txtTenNguonGoc_Enter(object sender, System.EventArgs e)
		{
			this.txtTenNguonGoc.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtTenNguonGoc_Leave(object sender, System.EventArgs e)
		{
			this.txtTenNguonGoc.BackColor =Color.White;
		}

		private void txtLoaikhoan_Enter(object sender, System.EventArgs e)
		{
			this.txtLoaikhoan.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtLoaikhoan_Leave(object sender, System.EventArgs e)
		{	
			this.txtLoaikhoan.BackColor =Color.White;
		}

		private void txtTenloaikhoan_Enter(object sender, System.EventArgs e)
		{
			this.txtTenloaikhoan.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(i_Red)), ((System.Byte)(i_Green)), ((System.Byte)(i_Blue)));
		}

		private void txtTenloaikhoan_Leave(object sender, System.EventArgs e)
		{
			this.txtTenloaikhoan.BackColor =Color.White;
		}
		#endregion

		private void cboChonQuy_SelectedValueChanged(object sender, System.EventArgs e)
		{
			try
			{
				switch (cboChonQuy.SelectedIndex)
				{
					case 0:
						numNam.Enabled=true;lblNam.Enabled=true;
						numQuy.Enabled=true;lblDenthang.Enabled=true;
						int i_Quy=(int)((int.Parse(DateTime.Now.Month.ToString())-1)/3)+1;
						numQuy.Value=i_Quy;						
						break;
					case 1:
						numQuy.Enabled=false;lblDenthang.Enabled=false;
						numNam.Enabled=true;lblNam.Enabled=true;
						numNam.Value=DateTime.Now.Year;						
						break;
					default:
						numQuy.Enabled=true;lblDenthang.Enabled=true;
						numNam.Enabled=true;lblNam.Enabled=true;
						numQuy.Focus();
						break;
				}
			}
			catch (Exception Ex)
			{
				MessageBox.Show("Error : " + Ex ,"Thông báo !");
			}
		}
		private void chkCheck_CheckedChanged(object sender, System.EventArgs e)
		{
			if (chkCheck.Checked)check=true;
			else check=false;
		}	
		#endregion

		#region Function
		private void f_Loadform()
		{
			i_HTaikhoan=2; i_HLoaikhoan=-2;
			switch (s_Tenform)
			{
				case "TongHopKP":
					f_Loadform_TinhHinhKP();
					break;
				case "QuyetToanKP":					
					f_Loadform_QuyetToanKP();
					break;
				case "QuyetToanKP_longan":					
					f_Loadform_QuyetToanKP();
					break;
				default:
					f_Loadform_Null();
					break;
			}
		}


		private void f_Loadform_Null()
		{
			try
			{
				this.Text="Báo cáo đang xây dựng!";					
				grpNen.Dispose(); 
				lblChuong.Dispose(); 
				lblLoaikhoan.Dispose(); 
				txtLoaikhoan.Dispose(); 
				txtTenloaikhoan.Dispose();
				lblHoatDong.Dispose();
				lblHoatDong.Dispose();
				butXem.Dispose(); butIn.Dispose(); 						
			}
			catch 
			{
				MessageBox.Show("Có lỗi xảy ra !", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
			}		
			
		}


		private void f_Loadform_TinhHinhKP()
		{
			this.Text="TỔNG HỢP TÌNH HÌNH KINH PHÍ";
			i_HTaikhoan=2; i_HLoaikhoan=-4;
			s_Report="KT_TongHopTinhHinhKP_QuyetToanKP1.rpt";
			chkCheck.Visible=false;			
			this.Height=264;
			grpNen.Height = 144;
		}


		private void f_Loadform_QuyetToanKP()
		{
			this.Text="TỔNG HỢP QUYẾT TOÁN KINH PHÍ ĐÃ QUA SỬ DỤNG";							
			i_HTaikhoan=2; i_HLoaikhoan=-4;	  
			if (check) s_Report="KT_TongHopTinhHinhKP_QuyetToanKP2.rpt";		
			else s_Report="KT_TongHopTinhHinhKP_QuyetToanKP2_.rpt";		
		}


		private void f_Loaddm()
		{				
			try
			{				
				// listbox NHOM BAO CAO
				dtDmnhombc=a.get_DMNhombc().Tables[0];		
				listnhombc.TextMember="ma";
				listnhombc.DisplayMember="ten";
				listnhombc.ValueMember="ten";
				listnhombc.DataSource=dtDmnhombc;
				//listbox CHUONG
				dtDmChuong=a.get_DMChuong().Tables[0];
				listchuong.TextMember="ma";
				listchuong.DisplayMember="ten";
				listchuong.ValueMember="ten";
				listchuong.DataSource=dtDmChuong;
				//listbox HOAT DONG
				dtDmHoatdong=a.get_DMHoatdong().Tables[0];
				listhoatdong.TextMember="ma";
				listhoatdong.DisplayMember="ten";
				listhoatdong.ValueMember="ten";
				listhoatdong.DataSource=dtDmHoatdong;
				//load LOAI KHOAN
				dtDmlk=a.get_DMLoaikhoan().Tables[0];
				listLoaikhoan.TextMember="lk";
				listLoaikhoan.DisplayMember="tlk";
				listLoaikhoan.ValueMember="tlk";
				listLoaikhoan.DataSource=dtDmlk;				
				// load NGUON
				dtDmNguon=a.get_DMNguon("").Tables[0];	
				listNguon.TextMember="mang";
				listNguon.DisplayMember="ten";
				listNguon.ValueMember="ten";
				listNguon.DataSource=dtDmNguon;
			}
			catch (Exception Ex)
			{
				MessageBox.Show("Error : " + Ex ,"Thông báo !");
			}
		}


		private void Filter_List(string s_Dkloc,int i_Loai)
		{
			try
			{
				switch (i_Loai)
				{						
						// load NHOM BAO CAO
					case 2:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listnhombc.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="ma like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						//load CHUONG
					case 3:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listchuong.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="ma like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						//load HOAT DONG
					case 4:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listhoatdong.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="ma like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						//load LOAI TAI KHOAN
					case 5:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listLoaikhoan.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="lk like '%"+s_Dkloc.Trim()+"%'";
						break;
					}
						//load NGUON KINH PHI
					case 6:
					{
						CurrencyManager cm= (CurrencyManager)BindingContext[listNguon.DataSource];
						System.Data.DataView dv=(System.Data.DataView)cm.List;
						dv.RowFilter="mang like '%"+s_Dkloc.Trim()+"%'";
						break;
					}					
					default:
						break;
				}

			}
			catch (Exception Ex)
			{
				MessageBox.Show("Error : " + Ex ,"Thông báo !");
			}
		}


		private void hide_List()
		{			
			if(!listnhombc.Focused) listnhombc.Hide();
			if(!listchuong.Focused) listchuong.Hide();
			if(!listhoatdong.Focused) listhoatdong.Hide();
			if(!listNguon.Focused) listNguon.Hide();			
			if(!listLoaikhoan.Focused) listLoaikhoan.Hide();
		}


		private void Display(int loai)
		{			
			int yy=int.Parse(numNam.Value.ToString());
			int mm1=0;
			int mm2=int.Parse(numQuy.Value.ToString());
			//Tinh lai cac gia tri thang theo dieu kien chon ngay thang.
			switch (cboChonQuy.SelectedIndex)
			{
				case 0:
					mm1=(mm2*3)-2;
					mm2=mm2*3;
					break;
				case 1:
					mm1=1;
					mm2=12;
					break;
			}

			string s_mm1=mm1.ToString().PadLeft(2,'0');
			string s_mm2=mm2.ToString().PadLeft(2,'0');
			string s_yyyy=yy.ToString().Trim();
			string s_yy=s_yyyy.Substring(2,2);

			string s_Thangnam=a.kt_Tinhsodu(s_mm2.ToString(),s_yy);
			if (s_Thangnam!="")
			{
				MessageBox.Show("Các tháng "+s_Thangnam.Substring(0,s_Thangnam.Length-1)+" chưa tính số dư!","Chú ý!");
				//xac minh co tinh so du
				if (MessageBox.Show ("Bạn có muốn kiểm tra số dư không ?",this.Text,MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
				{
					//tinh so du
					string sql="",_tu="",_den="";
					_den=s_mm2+s_yyyy.Substring(2,2);			
					//lay thang tu						
					sql="select mmyy from (select *  from a_dtsd where substr(trim(mmyy),3,4)='"+s_yy+"' order by mmyy asc) where rownum=1";
					DataSet ds=new DataSet();
					ds=a.get_data(sql);
					if(ds!=null && ds.Tables[0].Rows.Count>0)
						_tu=ds.Tables[0].Rows[0]["mmyy"].ToString();
					else _tu=s_mm1+s_yyyy.Substring(2,2);			
					if (!a.bYyyy(s_yyyy))
					{
						MessageBox.Show("Số liệu năm "+s_yyyy+" chưa tạo !",a.Msg);
						return;
					}
					string s=a.KiemtraFb(_tu,_den);
					if (s!="")
					{
						MessageBox.Show("Số liệu tháng :"+s.Substring(0,s.Length-1)+" Năm "+s_yyyy+" bị khóa !");    		
						return;
					}
					else 
					{
						Cursor=Cursors.WaitCursor;
						a.KiemtraFb(_tu,_den,i_Iduser);
						Cursor=Cursors.Default;
					}
					//a.updSodu(_tu,a.Mmyy_sau(_den),i_Iduser,false);
					MessageBox.Show("Đã kiểm tra số dư cuối tháng "+_tu.Substring(0,2)+" đến tháng "+_den.Substring(0,2)+" năm 20"+s_yy+" !",a.Msg);					
					//
				}
				return;
			}

			ngaythangnam="Từ Tháng " + s_mm1 + " Đến Tháng " + s_mm2 + " Năm " + s_yyyy; 
			frmReport_kp_class accMyform=new frmReport_kp_class();
			ds_Data=new DataSet();
			string s_IDlk="",idChuong="",idHoatdong="",idNguon="",idnhom="";
			try
			{
				if (txtLoaikhoan.Text!="") s_IDlk=a.getrowbyid(dtDmlk,"lk='"+txtLoaikhoan.Text.Trim()+"'")["id"].ToString().Trim();
				if (txtchuong.Text!="") idChuong=a.getrowbyid(dtDmChuong,"ma='"+txtchuong.Text.Trim()+"'")["id"].ToString().Trim();
				if (txthoatdong.Text!="") idHoatdong=a.getrowbyid(dtDmHoatdong,"ma='"+txthoatdong.Text.Trim()+"'")["id"].ToString().Trim();			
				if (txtNguonGoc.Text!="") idNguon=a.getrowbyid(dtDmNguon,"mang='"+txtNguonGoc.Text.Trim()+"'")["id"].ToString().Trim();
				if (txtnhombc.Text!="") idnhom=a.getrowbyid(dtDmnhombc,"ma='"+txtnhombc.Text.Trim()+"'")["id"].ToString().Trim();
				switch(s_Tenform)
				{
					case "QuyetToanKP":
						if (check) ds_Data=accMyform.QuyetToanKP(a,s_IDlk,idChuong,idHoatdong,idNguon,s_mm1,s_mm2,s_yy,idnhom);
						else ds_Data=accMyform.QuyetToanKP_(a,s_IDlk,idChuong,idHoatdong,idNguon,s_mm1,s_mm2,s_yy,idnhom);
						break;
					case "QuyetToanKP_longan":
						if (check) ds_Data=accMyform.QuyetToanKP_la(a,s_IDlk,idChuong,idHoatdong,idNguon,s_mm1,s_mm2,s_yy,idnhom);					
						else ds_Data  = accMyform.QuyetToanKP_La_(a,s_IDlk,idChuong,idHoatdong,idNguon,s_mm1,s_mm2,s_yy,idnhom);
						break;
				}
				accMyform.Dispose();
			}
			catch (Exception Ex)
			{
				MessageBox.Show("Error : " + Ex ,"Thông báo !");
			}
			
					
			try
			{
				if (ds_Data==null) MessageBox.Show("Không có số liệu !","Thông báo !");
				else
				{
					switch(loai)
					{
						case 1:							
							if (txtLoaikhoan.Text!="")
							{
								s_loai = txtLoaikhoan.Text.Trim().Split('-')[0].ToString();
								s_khoan= txtLoaikhoan.Text.Trim().Split('-')[1].ToString();
							}		
							if (cboChonQuy.Text=="Năm")
								text = "Năm " + numNam.Value.ToString();
							else text = "Quý " + numQuy.Value.ToString() + " Năm " + numNam.Value.ToString();
							if(s_Tenform=="QuyetToanKP_longan")
							{
								if (check)
								{													
									frmReport f=new frmReport(a,ds_Data,"KT_TongHopTinhHinhKP_QuyetToanKP2la.rpt",s_loai,s_khoan,ngayin,Madvqhns,text);								
									f.ShowDialog();	
									frmReport fa=new frmReport(a,ds_Data,"KT_TongHopTinhHinhKP_QuyetToanKP2la1.rpt",s_loai,s_khoan,ngayin,Madvqhns,text);								
									fa.ShowDialog();	
								}
													
								else
								{
									frmReport f=new frmReport(a,ds_Data,"KT_TongHopTinhHinhKP_QuyetToanKP2_la.rpt",s_loai,s_khoan,ngayin,Madvqhns,text);
									f.ShowDialog();
									frmReport fa=new frmReport(a,ds_Data,"KT_TongHopTinhHinhKP_QuyetToanKP2_la1.rpt",s_loai,s_khoan,ngayin,Madvqhns,text);
									fa.ShowDialog();
								}
							}
							else
							{
								if (check)
								{
									frmReport f=new frmReport(a,ds_Data,"KT_TongHopTinhHinhKP_QuyetToanKP2.rpt",s_loai,s_khoan,ngayin,Madvqhns,text);
									f.ShowDialog();	
								}
						
								else
								{
									frmReport f=new frmReport(a,ds_Data,"KT_TongHopTinhHinhKP_QuyetToanKP2_.rpt",s_loai,s_khoan,ngayin,Madvqhns,text);
									f.ShowDialog();	
								}
							}
							break;						
						case 2:
							string s_ExcelError=exportExcel.expExcel(a,ds_Data,"",ngaythangnam,"","","","","","","","","","","",s_Report.ToString());
							if (s_ExcelError!="")
								MessageBox.Show(s_ExcelError,"Thông báo!");
							break;
						default: 
							break;
						}
//				else Print.Printer(a,ds_Data,s_Report.ToString(),1);
				}
			}
			catch (Exception Ex)
			{
				MessageBox.Show("Error : " + Ex ,"Thông báo !");
			}
			
		}


		private void Display_(int loai)
		{

		}
		#endregion	
	
	}
}
